package Test3_13;

import java.util.Arrays;
import java.util.Random;

public class Problem03 {
    /**
     * 有6名评委给选手打分，分数范围是[0 - 100]之间的整数。
     * 选手的最后得分为：去掉最高分、最低分后的4个评委的平均分，
     * 请完成上述过程并计算出选手的得分。
     *
     * @return
     */
    public static void point(){
        System.out.println("六个评委打分分别为：");
        double[] num=new double[6];
        double[] num1=new double[num.length-2];
        Random ra=new Random();
        for (int i = 0; i < num.length; i++) {
            num[i]= ra.nextInt(100);
        }
        // System.out.print(Arrays.toString(num));
        for (int i = 0; i < num.length-1; i++) {
            for (int j = 0; j < num.length-1-i; j++) {
                if(num[j]>num[j+1]){
                    double temp=num[j];
                    num[j]=num[j+1];
                    num[j+1]=temp;
                }
            }
        }
        System.out.println(Arrays.toString(num)+"   ");
        System.out.println("去掉最高分和最低分剩下的为：");
        System.arraycopy(num,1,num1,0,num.length-2);
        num=num1;
        System.out.println(Arrays.toString(num));
        System.out.println("选手最后得分为：");
        double sum=0.0;
        double avg=0.0;
        for (int i = 0; i < num.length; i++) {
            sum+=num[i];
            avg=sum/4;
        }
        System.out.println(avg);
    }

    public static void main(String[] args) {

        point();
    }
}

